<%@ page language="java" import="java.util.*,java.sql.*"
	contentType="text/html; charset=utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<jsp:useBean id="db" class="connBean.ConnDB" scope="page" />

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>欧米购商城</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">


		<link rel="stylesheet" href="css/style.css" type="text/css"
			media="all" />
		<!--[if lte IE 6]><link rel="stylesheet" href="css/ie6.css" type="text/css" media="all" /><![endif]-->

		<meta name="keywwords"
			content="Shop Around - Great free html template for on-line shop. Use it as a start point for your on line business. The template can be easily implemented in many open source E-commerce platforms" />
		<meta name="description"
			content="Shop Around - Great free html template for on-line shop. Use it as a start point for your on line business. The template can be easily implemented in many open source E-commerce platforms" />

		<!-- JS -->
		<script src="js/jquery-1.4.1.min.js" type="text/javascript">
</script>
		<script src="js/jquery.jcarousel.pack.js" type="text/javascript">
</script>
		<script src="js/jquery-func.js" type="text/javascript">
</script>
		<!-- End JS -->


		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
		<script type="text/JavaScript">
</script>

	</head>
	<body>
		<%
			request.setCharacterEncoding("UTF-8");
		%>
		<jsp:include page="customerService.jsp"></jsp:include>
		<!-- Shell -->
		<div class="shell">

			<!-- Header -->
			<div id="header">
				<h1 id="logo">
					<a href="index.jsp">欧米购</a>
				</h1>
				<!-- Cart -->
				<div id="cart" align="center">
					<%
						if (session.getAttribute("username") == null
								|| session.getAttribute("username") == "") {
					%>您好，您还未登录！
					<div class="cl">
						&nbsp;
					</div>
					<a href="login.jsp" class="c2-link">[登录]</a>
					<a href="addUser.jsp" class="c2-link">[免费注册]</a>
					<%
						} else {
					%>欢迎您，<%=session.getAttribute("username")%>
					<a href="logout.jsp" class="c2-link">[退出]</a>
					<div class="cl">
						&nbsp;
					</div>
					<a href="personalData.jsp" class="c2-link">我的欧米购</a>
					<a href="shoppingCart.jsp" class="cart-link">我的购物车</a>
					<%
						}
					%>
				</div>
				<!-- End Cart -->

				<!-- Navigation -->
				<div id="navigation">
					<ul>
						<li>
							<a href="index.jsp">主页</a>
						</li>
						<%
							db.OpenConn();
							db.createStmt();
							String sql = "select * from main_type";
							ResultSet rs = db.Query(sql);
							while (rs.next()) {
						%>
						<li>
							<a href="index_main_Type.jsp?maintype_id=<%=rs.getInt("t_id")%>"><%=rs.getString("t_name")%></a>
						</li>
						<%
							}
							db.closeStmt();
							db.closeConn();
						%>
					</ul>
				</div>
				<!-- End Navigation -->
			</div>
			<!-- End Header -->

			<!-- Main -->
			<div id="main">
				<div class="cl">
					&nbsp;
				</div>

				<!-- Content -->
				<div id="content">

					<!-- Content Slider -->
					<div id="slider" class="box">
						<div id="slider-holder">
							<ul>
							    <%db.OpenConn();
							    db.createStmt();
							    String topsql="select * from product";
							    ResultSet products=db.Query(topsql);
							    while(products.next()){
							    String pid=products.getString("p_id");
							    if(pid.equals("1")||pid.equals("fz-nz-03")||pid.equals("sp-xx-01")||pid.equals("sp-yl-03"))
							    {
							    String images=products.getString("p_image");
							    String []image=images.split(";");
							     %>
								<li>
									<a href="index_ProductDetail.jsp?p_id=<%=pid %>"><img src="images/<%=image[2] %>" alt="" />
									</a>
								</li>
								<%}
								}db.closeStmt();
								db.closeConn();
								 %>
							</ul>
						</div>
						<div id="slider-nav">
							<a href="#" class="active">1</a>
							<a href="#">2</a>
							<a href="#">3</a>
							<a href="#">4</a>
						</div>
					</div>
					<!-- End Content Slider -->

					<!-- Products -->
					<div class="products">
						<div class="cl">
							&nbsp;
						</div>
						<%db.OpenConn();
						db.createStmt();
						String centersql="select p.p_id,p.p_name,s.st_name,p.p_price,p.p_quantity,p.p_image,p.p_description,p.p_time,p.p_status from product as p left join second_type as s on p.st_id=s.st_id";
						ResultSet products2=db.Query(centersql);
						int count=0;
						while(products2.next())
				  {count++;
				   if(count%3==1){
				   %>
				   <ul>
				    <li>
				    	<a href="index_ProductDetail.jsp?p_id=<%=products2.getString("p_id") %>" target="_blank"><img src="images/<%String p_image=products2.getString("p_image");String []images=p_image.split(";");out.print(images[1]);%>" alt="" /></a>
				    	<div class="product-info">
				    		<h3><%if(products2.getInt("p_status")==0)out.print("新品上市");
				    		      else if(products2.getInt("p_status")==1)out.print("普通商品");
				    		      else if(products2.getInt("p_status")==2)out.print("特价商品"); %></h3>
				    		<div class="product-desc">
								<h4><%=products2.getString("st_name") %></h4>
				    			<p><%=products2.getString("p_name") %></p>
				    			<strong class="price">￥<%=products2.getFloat("p_price") %></strong>
				    		</div>
				    	</div>
			    	</li>
			    	<%}
			    	else if(count%3==2){
			    	%>
			    	<li>
				    	<a href="index_ProductDetail.jsp?p_id=<%=products2.getString("p_id") %>" target="_blank"><img src="images/<%String p_image=products2.getString("p_image");String []images=p_image.split(";");out.print(images[1]);%>" alt="" /></a>
				    	<div class="product-info">
				    		<h3><%if(products2.getInt("p_status")==0)out.print("新品上市");
				    		      else if(products2.getInt("p_status")==1)out.print("普通商品");
				    		      else if(products2.getInt("p_status")==2)out.print("特价商品"); %></h3>
				    		<div class="product-desc">
								<h4><%=products2.getString("st_name") %></h4>
				    			<p><%=products2.getString("p_name") %></p>
				    			<strong class="price">￥<%=products2.getFloat("p_price") %></strong>
				    		</div>
				    	</div>
			    	</li>
			    	<%}
			    	else{%>
			    	<li class="last">
				    	<a href="index_ProductDetail.jsp?p_id=<%=products2.getString("p_id") %>" target="_blank"><img src="images/<%String p_image=products2.getString("p_image");String []images=p_image.split(";");out.print(images[1]);%>" alt="" /></a>
				    	<div class="product-info">
				    		<h3><%if(products2.getInt("p_status")==0)out.print("新品上市");
				    		      else if(products2.getInt("p_status")==1)out.print("普通商品");
				    		      else if(products2.getInt("p_status")==2)out.print("特价商品"); %></h3>
				    		<div class="product-desc">
								<h4><%=products2.getString("st_name") %></h4>
				    			<p><%=products2.getString("p_name") %></p>
				    			<strong class="price">￥<%=products2.getFloat("p_price") %></strong>
				    		</div>
				    	</div>
			    	</li>
			    	</ul>
			    	<%}
			    	if(count==3) break;
			    	}
						
						 %>
						<div class="cl">
							&nbsp;
						</div>
					</div>
					<!-- End Products -->

				</div>
				<!-- End Content -->

				<!-- Sidebar -->
				<div id="sidebar">

					<!-- Search -->
					<div class="box search">
						<h2>
							搜索商品
							<span></span>
						</h2>
						<div class="box-content">
							<form action="searchProducts.jsp?maintype_id=0" method="post">

								<label>
									关键字
								</label>
								<input name="mainkey" type="text" class="field" />

								<label>
									商品种类
								</label>
								<select name="second_type" class="field">
									<option value="0">
										选择种类
									</option>
									<%
										db.OpenConn();
										db.createStmt();
										String sql_type = "select * from second_type";
										ResultSet second_type = db.Query(sql_type);
										while (second_type.next()) {
									%>
									<option value="<%=second_type.getInt("st_id")%>"><%=second_type.getString("st_name")%></option>
									<%
										}
										db.closeStmt();
										db.closeConn();
									%>
								</select>

								<div class="inline-field">
									<label>
										价格区间
									</label>
									<select name="price_1" class="field small-field">
										<option value="0">
											选择下限
										</option>
										<option value="10">
											￥10
										</option>
										<option value="50">
											￥50
										</option>
										<option value="100">
											￥100
										</option>
										<option value="200">
											￥200
										</option>
										<option value="500">
											￥500
										</option>
									</select>
									<label>
										至:
									</label>
									<select name="price_2" class="field small-field">
										<option value="1000000000">
											选择上限
										</option>
										<option value="50">
											￥50
										</option>
										<option value="100">
											￥100
										</option>
										<option value="200">
											￥200
										</option>
										<option value="500">
											￥500
										</option>
										<option value="1000">
											￥1000
										</option>
									</select>
								</div>

								<input type="submit" class="search-submit" value="搜索" />

								<p>
									<a href="personalData_Favorite.jsp" class="bul">个人收藏夹</a>
									<br />
								</p>

							</form>
						</div>
					</div>
					<!-- End Search -->

					<!-- Categories -->
					<div class="box categories">
						<h2>
							公告栏
							<span></span>
						</h2>
						<div class="box-content">
							<ul>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<%
									db.OpenConn();
									db.createStmt();
									String ggsql = "select * from notice order by n_time desc";
									ResultSet gg = db.Query(ggsql);
									if (gg.next()) {
										out.print(gg.getString("n_message"));
									}
								%>
							</ul>
						</div>
					</div>
					<!-- End Categories -->

				</div>
				<!-- End Sidebar -->

				<div class="cl">
					&nbsp;
				</div>
			</div>
			<!-- End Main -->

			<!-- Side Full -->
			<div class="side-full">

				<!-- More Products -->
				<div class="more-products">
					<div class="more-products-holder">
						<ul>
							<li>
								<a href="#"><img src="images/small1.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small2.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small3.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small4.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small5.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small6.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small7.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small1.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small2.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small3.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small4.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small5.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small6.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small7.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small1.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small2.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small3.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small4.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small5.jpg" alt="" />
								</a>
							</li>
							<li>
								<a href="#"><img src="images/small6.jpg" alt="" />
								</a>
							</li>
							<li class="last">
								<a href="#"><img src="images/small7.jpg" alt="" />
								</a>
							</li>
						</ul>
					</div>
					<div class="more-nav">
						<a href="#" class="prev">previous</a>
						<a href="#" class="next">next</a>
					</div>
				</div>
				<!-- End More Products -->

				<!-- Text Cols -->
				<div class="cols">
					<div class="cl">
						&nbsp;
					</div>
					<div class="col">
						<h3 class="ico ico1">
							Donec imperdiet
						</h3>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
							imperdiet, metus ac cursus auctor, arcu felis ornare dui.
						</p>
						<p class="more">
							<a href="#" class="bul">Lorem ipsum</a>
						</p>
					</div>
					<div class="col">
						<h3 class="ico ico2">
							Donec imperdiet
						</h3>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
							imperdiet, metus ac cursus auctor, arcu felis ornare dui.
						</p>
						<p class="more">
							<a href="#" class="bul">Lorem ipsum</a>
						</p>
					</div>
					<div class="col">
						<h3 class="ico ico3">
							Donec imperdiet
						</h3>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
							imperdiet, metus ac cursus auctor, arcu felis ornare dui.
						</p>
						<p class="more">
							<a href="#" class="bul">Lorem ipsum</a>
						</p>
					</div>
					<div class="col col-last">
						<h3 class="ico ico4">
							Donec imperdiet
						</h3>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec
							imperdiet, metus ac cursus auctor, arcu felis ornare dui.
						</p>
						<p class="more">
							<a href="#" class="bul">Lorem ipsum</a>
						</p>
					</div>
					<div class="cl">
						&nbsp;
					</div>
				</div>
				<!-- End Text Cols -->

			</div>
			<!-- End Side Full -->

			<!-- Footer -->
			<div id="footer">
				<p class="left">
					<a href="index.jsp">Home</a>
					<span>|</span>
					<a href="#">Support</a>
					<span>|</span>
					<a href="#">My Account</a>
					<span>|</span>
					<a href="#">The Store</a>
					<span>|</span>
					<a href="#">Contact</a>
				</p>
				<p class="right">
					&copy; 2015 OMEGO Shopping Design by &nbsp;
					<a href="#" target="_blank"
						title="The Sweetest CSS Templates WorldWide">欧米购创意小组</a>
				</p>
			</div>
			<!-- End Footer -->

		</div>
		<!-- End Shell -->


	</body>
</html>
